package com.twu.biblioteca;

import java.io.IOException;

/**
 * Created by sahelig on 20/06/14.
 */
public class Login implements MenuAction {


        public Result performAction(UserInterface ui,String libraryNumberInput)throws IOException
        {
            Users users=new Users();
            ui.display("Login to Application");
            ui.display("\n\nPlease Enter Login details\n\n");
            try
            {
                String libraryNumber = ui.takeInputForLibraryNumber();
                String password = ui.takeInputForPassword();

                if (users.verifyDetailsDuringLogin(libraryNumber, password))
                    return new Result(true,libraryNumber);

            }
            catch (Exception e)
            {
                ui.display("Invalid input!....please enter again!");
            }


            return new Result(false,null);
        }

        @Override
        public String toString() {
        return "to Login to Application";
    }

}
